﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI.Extensions;

namespace Leon.UI
{
    
    [AddComponentMenu("Leon.UI/HorizontialScrollViewUIDrag")]
    [RequireComponent(typeof(UnityEngine.UI.Extensions.Scroller))]
    public class ScrollView : FancyScrollView<UserItem>
    {
        [SerializeField]
        GameObject cellPrefab;
        [SerializeField]
        Scroller scroller;
        protected override GameObject CellPrefab => cellPrefab;

        protected override void Initialize()
        {
            base.Initialize();
            scroller.OnValueChanged(UpdatePosition);
        }

        public void UpdateData(IList<UserItem> data)
        {
            UpdateContents(data);
            scroller.SetTotalCount(data.Count);
        }
    }
}